package com.yupi.exception;

import com.yupi.common.ErrorCode;
import lombok.Getter;

/**
 * 统一异常处理类
 */
@Getter
public class BusinessException extends RuntimeException {
    /**
     * code  错误码
     * description 错误详情
     */
    private final int code;
    private final String description;

    public BusinessException(String message, int code, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.description = description;
    }
}
